﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace testArrByte
{
    public partial class Form1 : Form
    {
        [DllImport("arrBstr", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int bstrToarr(ref byte vbstr, ref float p, int n);
        [DllImport("arrBstr", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int arrTobstr(ref byte b, ref float v, int n);
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Dim b() As Byte
            //ReDim b(n * 4 - 1)
            //Call arrTobstr(b(0), v, n)
            int i;
            int n=100;
            float[] x=new float[100];
            float[] y=new float[100];
            byte[]b=new byte[n*4];
            for(i=0;i<n;i++)
            {
                x[i] = i;
            } 
            arrTobstr(ref b[0], ref x[0], n);
            bstrToarr(ref b[0], ref y[0], n);
        }
    }
}
